The Pascal script can contain several event functions which are called at appropriate times.
Setup supports following event functions:
Called during Setup's initialization. Return False to abort Setup, True otherwise.
Use this event function to make changes to the wizard or wizard pages at startup. You can't use the InitializeSetup event function for this since at the time it is triggered, the wizard form does not yet exist.
Called just before Setup terminates. Note that this function is called even if the user exits Setup before anything is installed.
You can use this event function to perform your own pre-install and post-install tasks.
Called with CurStep=ssInstall just before the actual installation starts, with CurStep=ssPostInstall just after the actual installation finishes, and with CurStep=ssDone just before Setup terminates after a successful install.
Called when the user clicks the Next button. If you return True, the wizard will move to the next page; if you return False, it will remain on the current page (specified by CurPageID).
Note that this function is called on silent installs as well, even though there is no Next button that the user can click. Setup instead simulates "clicks" on the Next button. On a silent install, if your NextButtonClick function returns False prior to installation starting, Setup will exit automatically.
Called when the user clicks the Back button. If you return True, the wizard will move to the previous page; if you return False, it will remain on the current page (specified by CurPageID).
Called when the user clicks the Cancel button or clicks the window's Close button. The Cancel parameter specifies whether normal cancel processing should occur; it defaults to True. The Confirm parameter specifies whether an "Exit Setup?" message box should be displayed; it usually defaults to True. If Cancel is set to False, then the value of Confirm is ignored.
The wizard calls this event function to determine whether or not a particular page (specified by PageID) should be shown at all. If you return True, the page will be skipped; if you return False, the page may be shown.
Note: This event function isn't called for the wpWelcome, wpPreparing, and wpInstalling pages, nor for pages that Setup has already determined should be skipped (for example, wpSelectComponents in an install containing no components).
Called after a new wizard page (specified by CurPageID) is shown.
If Setup finds the CheckPassword event function in the Pascal script, it automatically displays the Password page and calls CheckPassword to check passwords. Return True to accept the password and False to reject it.
To avoid storing the actual password inside the compiled [Code] section which is stored inside Setup, you should use comparisons by hash only: calculate the MD5 hash of your password yourself and then compare that to GetMD5OfString(Password). This way the actual value of the password remains protected.
Note: if you have a CheckPassword event function and your users run Setup with both the "/PASSWORD=" and "/SILENT" command line parameters set, your CheckPassword function will be called *before* any other event function is called, including InitializeSetup.
Return True to instruct Setup to prompt the user to restart the system at the end of a successful installation, False otherwise.
If Setup finds the UpdateReadyMemo event function in the Pascal script, it is called automatically when the Ready to Install wizard page becomes the active page. It should return the text to be displayed in the settings memo on the Ready to Install wizard page as a single string with lines separated by the NewLine parameter. Parameter Space contains a string with spaces. Setup uses this string to indent settings. The other parameters contain the (possibly empty) strings that Setup would have used as the setting sections. The MemoDirInfo parameter for example contains the string for the Selected Directory section.
To store user settings entered on custom wizard pages, place a RegisterPreviousData event function in the Pascal script and call SetPreviousData(PreviousDataKey, ...) inside it, once per setting.
If Setup finds the CheckSerial event function in the Pascal script, a serial number field will automatically appear on the User Info wizard page (which must be enabled using UserInfoPage=yes in your [Setup] section!). Return True to accept the serial number and False to reject it. When using serial numbers, it's important to keep in mind that since no encryption is used and the source code to Inno Setup is freely available, it would not be too difficult for an experienced individual to remove the serial number protection from an installation. Use this only as a convienience to the end user and double check the entered serial number (stored in the {userinfoserial} constant) in your application.
Return a non zero number to instruct Setup to return a custom exit code. This function is only called if Setup was successfully run to completion and the exit code would have been 0. Also see Setup Exit Codes.
Uninstall supports following event functions:
Return False to abort Uninstall, True otherwise.
Return True to instruct Uninstall to prompt the user to restart the system at the end of a successful uninstallation, False otherwise.
Here's the list of constants used by these functions:
None of these functions are required to be present in a Pascal script.